/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/rectangle-area
   @Language: C++
   @Datetime: 20-01-15 15:43
   */

class Solution {
public:
	int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
		int w=min(C,G)>max(A,E)?min(C,G)-max(A,E):0;
		int h=min(D,H)>max(B,F)?min(D,H)-max(B,F):0;
		return (C-A)*(D-B)-w*h+(G-E)*(H-F);
	}
};
